package com.hzqy.service.flight;

import com.hzqy.persistence.dao.flight.FlightInformationDao;
import com.hzqy.persistence.dao.industry.IndustryDao;
import com.hzqy.service.core.GenericServiceBean;
import com.hzqy.web.vo.flight.FlightInformationVo;
import com.hzqy.web.vo.industry.ZjDataOpenInterfaceDatasVo;
import com.hzqy.web.vo.industry.ZjZheJiangServiceVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class FlightInformationServiceBean extends GenericServiceBean<FlightInformationVo, FlightInformationDao, Integer> {

    protected final Logger LOG = LoggerFactory.getLogger(getClass());
    private static final long serialVersionUID = 1L;

    @Resource
    private FlightInformationDao flightInformationDao;
    @Override
    public FlightInformationDao getEntityDao() {
        return flightInformationDao;
    }

    public Map<String, Object> selectFlightInformationList(FlightInformationVo flightInformationVo, int curPage, int pageSize) {
        Map<String,Object> map = new HashMap<String, Object>();
        Integer rowCount = flightInformationDao.selectFlightInformationCount(flightInformationVo);
        map.put("total", rowCount);
        if(rowCount > 0 && curPage > 0 && pageSize > 0) {
            map.put("firstResult", (curPage-1)*pageSize);
            map.put("maxResults", pageSize);
            map.put("startCity", flightInformationVo.getStartCity());
            map.put("lastCity", flightInformationVo.getLastCity());
            map.put("AirlineCode", flightInformationVo.getAirlineCode());
            List<FlightInformationVo> results = flightInformationDao.selectFlightInformationList(map);
            map.put("rows", results);
        } else {
            map.put("rows", new ArrayList<ZjDataOpenInterfaceDatasVo>());
        }
        return map;
    }
}
